package com.lkx.farmershop.controller;

import com.lkx.farmershop.common.api.ApiResult;
import com.lkx.farmershop.model.dto.QueryObj;
import com.lkx.farmershop.model.vo.GroupVo;
import com.lkx.farmershop.model.vo.SimpleUserVo;
import com.lkx.farmershop.service.IFarmerService;
import com.lkx.farmershop.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private TagService tagService;
    @Autowired
    private IFarmerService farmerService;

    /**
     * 推荐搜索列表
     * @param query
     * @return
     */
    @GetMapping("/searchByQuery")
    public ApiResult<List<String>> searchByQuery(String query) {
        return tagService.seachByQuery(query);
    }

    /**
     * 根据内容搜索组团
     * @param queryObj
     * @return
     */
    @GetMapping("/searchByName")
    public ApiResult<List<GroupVo>> searchByName(QueryObj queryObj) {
        return tagService.searchByName(queryObj);
    }

    /**
     * 根据标签搜索组团
     * @param queryObj
     * @return
     */
    @GetMapping("/searchByTag")
    public ApiResult<List<GroupVo>> searchByTag(QueryObj queryObj) {
        return tagService.searchByTag(queryObj);
    }

    /**
     * 搜索用户
     * @param queryObj
     * @return
     */
    @GetMapping("/searchUser")
    public ApiResult<List<SimpleUserVo>> searchUser(QueryObj queryObj) {
        return farmerService.searchUser(queryObj);
    }
}
